package cn.wk.org.controller;

import cn.wk.basic.utils.AjaxResult;
import cn.wk.org.domain.Rejected;
import cn.wk.org.domain.Shop;
import cn.wk.org.service.IRejectedService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.mail.MessagingException;
import java.util.List;

@RestController
@RequestMapping("/rejected")
public class RejectedController {
    @Autowired
    private IRejectedService rejectedService;

    /**
     * 查询驳回选项
     * @return
     */
    @PostMapping()
    public List<Rejected> findRejected(){
        return rejectedService.findRejected();
    }

    /**
     * 根据id查询店铺
     * @param shop
     * @return
     */
    @PostMapping("/shop")
    public Shop findShopById(@RequestBody Shop shop){
        System.out.println(shop.getId());
        return rejectedService.findShopById(shop.getId());
    }

    /**
     * 驳回确定
     */
    @PostMapping("/sendReject")
    public AjaxResult sendReject(@RequestBody Rejected rejected) throws MessagingException {
        System.out.println(rejected);
        rejectedService.sendReject(rejected);
        return null;
    }
}
